package com.example.simpleproject.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import com.example.simpleproject.service.IDictService;
import com.example.simpleproject.entity.Dict;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liang
 * @since 2022-03-13
 */
@RestController
@RequestMapping("/dict")
        public class DictController {
    @Resource
private IDictService dictService;
@PostMapping
public Boolean save(@RequestBody Dict dict){
        return dictService.saveOrUpdate(dict);
        }
@DeleteMapping("/{id}")
public Boolean delete(@PathVariable Integer id){
        return dictService.removeById(id);
        }

@GetMapping
public List<Dict> findAll(){
        return dictService.list();
        }

@GetMapping("/{id}")
public List<Dict> findOne(@PathVariable Integer id){
        return dictService.list();
        }

@GetMapping("/page")
public Page<Dict> findPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize){
        return dictService.page(new Page<>(pageNum,pageSize));
        }
@PostMapping("/del/batch")
public boolean deleteBatch(@RequestBody List<Integer> ids){
        return dictService.removeByIds(ids);
        }
        }

